package com.ljc.utils;

import com.ljc.model.Match;
import com.ljc.model.MatchHistory;
import com.ljc.model.Match;
import org.apache.commons.collections.map.HashedMap;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class dotahelper {


    public static List<MatchHistory> res(String account_id) throws IOException {
    Map<String,Object> modelMap = new HashMap<String,Object>();
    String jsonArray = "";
        String steamKey = "FDB7DBEC429C094E7AEABF3CC50FCB1F";
        if (account_id == null || account_id .equals("")) {
        jsonArray = URLUtil.getUrlForMatchHistory("https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=" + steamKey + "&account_id=" + 191017855);
    }else{
        jsonArray = URLUtil.getUrlForMatchHistory("https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=" + steamKey + "&account_id=" + account_id);
    }
    List<MatchHistory> matchHistories = GsonUtil.getObjectList(jsonArray,MatchHistory.class);
        for (MatchHistory matchHistory:matchHistories){
        String startTime = String.valueOf(matchHistory.getStart_time());
        String normalStartTime = DateUtil.TimeStamp2Date(startTime);
        matchHistory.setString_start_time(normalStartTime);
    }
    Map<String,Object> data = new HashedMap();
        modelMap.put("data",data);
        data.put("list",matchHistories);
        data.put("total",matchHistories.size());
        modelMap.put("success",true);
        return matchHistories;
}

    public static List<Match> getmatch(){
        String filePath = "C:\\Users\\79133\\Desktop\\2.json";
        String jsonContent = FileUtil.ReadFile(filePath);

        List<Match> maps = GsonUtil.getObjectList(jsonContent, Match.class);

        return maps;
    }
public static void main(String[] args) throws IOException {
        res("187709004");

}
}
